﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Collections.Generic;
using System.Data.Common;
using NetBay.Core.BusinessEntities;
using NetBay.Core.Extensions;
using NetBay.Core.Log;
using System.Data;
#endregion

namespace Rio.Doc.Business.Repository.Translator
{
    public class ParamMessageFlowTranslator
    {
        /// <summary>
        /// Translate a bunch of ParamMessageFlow DataReader to ParamMessageFlow object
        /// </summary>
        /// <param name="P_oDbDataReader">The dataReader that contains the rows</param>
        /// <returns>A list of ParamMessageFlow Object</returns>
        public static List<ParamMessageFlow> TranslateParamMessageFlow(IDataReader P_oDbDataReader)
        {
             var l_lstParamMessageFlow = new List<ParamMessageFlow>();

            try
            {
                using (P_oDbDataReader)
                {
                    //Loop on all ParamMessageFlow
                    while (P_oDbDataReader.Read())
                    {
                        var l_oParamMessageFlow = new ParamMessageFlow();
                        //We populate all other informations on a ParamMessageFlow
                        l_oParamMessageFlow.TdId =
                            Convert.ToInt32(
                                P_oDbDataReader[ParamMessageFlow.Column.TdId.szGetDescription()].ToString());
                        l_oParamMessageFlow.ChronoTypeId =
                            Convert.ToInt32(
                                P_oDbDataReader[ParamMessageFlow.Column.ChronoTypeId.szGetDescription()].ToString());
                        l_lstParamMessageFlow.Add(l_oParamMessageFlow);
                    }
                }
            }
            catch (Exception ex)
            {
                NetBay.Core.Log.LogManager.Instance().LogError(NetBay.Core.Diagnostics.Method.GetMethodBaseName(NetBay.Core.Diagnostics.Method.Level.Father) + " EXCEPTION -> " + Environment.NewLine + ex);
            }

            return l_lstParamMessageFlow;
        }
    }
}
